import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/**
 * vue-loader13.0有一个变更就是默认启用了esModule
 */
const Main = Vue.extend(require('@/views/merchant/main.vue').default)
const Sale = Vue.extend(require('@/views/salesman/main.vue').default)

const _import = file => require('@/views/' + file + '.vue').default

const routes = [
  {
    path: '/merchant',
    component: Main,
    redirect: 'index',
    children: [
      { path: 'index', component: _import('merchant/base'), name: 'base' , meta: { back: false }},
      { path: 'bank', component: _import('merchant/bank'), name: 'bank', meta: { back: false }},
      { path: 'principal', component: _import('merchant/principal'), name: 'principal', meta: { back: false }},
      { path: 'leader', component: _import('merchant/leader'), name: 'leader', meta: { back: false }},
      { path: 'success', component: _import('merchant/success'), name: 'success', meta: { back: false }}
    ]
  },
  {
    path: '',
    component: Sale,
    redirect: 'index',
    children: [
      { path: 'index', component: _import('salesman/index'), name: 'saleman' },
      { path: 'login', component: _import('salesman/login'), name: 'login' },
      { path: 'qrCode', component: _import('salesman/qrcode'), name: 'qrCode' },
      { path: 'item', component: _import('salesman/merchant/index'), name: 'merchant' },
      { path: 'channelValid', component: _import('salesman/merchant/channel_valid'), name: 'channelValid' },
      { path: 'channelLeInfo', component: _import('salesman/merchant/channel_le_info'), name: 'leInfo' },
      { path: 'channelWs', component: _import('salesman/merchant/channel_ws'), name: 'channel_ws' },
      { path: 'channelLe', component: _import('salesman/merchant/channel_le'), name: 'channel_le' },
      { path: 'channelList', component: _import('salesman/merchant/channel_list'), name: 'channel_list' },
      { path: 'succ', component: _import('salesman/success'), name: 'channelSucc' },
      { path: 'merchantList', component: _import('salesman/merchant/list'), name: 'merchantList' },
      { path: 'baseList', component: _import('salesman/merchant/list'), name: 'baseList' }
    ]
  }
]

const router =  new Router({
  routes
})

export default router